//
//  THHomeViewController.m
//  THImageEditDemo
//
//  Created by 希达 on 2018/5/16.
//  Copyright © 2018年 Tan.huang. All rights reserved.
//

#import "THHomeViewController.h"
#import "THHomeTableViewCell.h"

@interface THHomeViewController () <UITableViewDelegate, UITableViewDataSource, SDCycleScrollViewDelegate>
@property (weak, nonatomic) UITableView *tableView;
@property (weak, nonatomic) SDCycleScrollView *cycleScrollView;
@property (strong, nonatomic) NSMutableArray *dataArray;
@property (strong, nonatomic) NSMutableArray *imageArray;
@end

@implementation THHomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"上酒中心";
    self.view.backgroundColor = [UIColor whiteColor];

    [self configView];
    [self configHeadView];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)configView {
    UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
    tableView.backgroundColor = [UIColor colorWithRed:238/255.0 green:238/255.0 blue:238/255.0 alpha:1];
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.rowHeight = 20;
    tableView.sectionHeaderHeight = 30;
    [self.view addSubview:tableView];
    [tableView registerClass:[THHomeTableViewCell class] forCellReuseIdentifier:@"THHomeTableViewCell"];
    [tableView registerClass:[THInfoHeaderView class] forHeaderFooterViewReuseIdentifier:@"THInfoHeaderView"];
    self.tableView = tableView;
}

- (void)configHeadView {
    SDCycleScrollView *cycleScrollView = [[SDCycleScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.tz_width, self.view.tz_width * 0.64)];
    cycleScrollView.delegate = self;
    cycleScrollView.localizationImageNamesGroup = @[@"iocn_0", @"iocn_1", @"iocn_2", @"iocn_3", @"iocn_4"];
    [self.tableView setTableHeaderView:cycleScrollView];
    self.cycleScrollView = cycleScrollView;
}

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
    NSLog(@"didSelectItemAtIndex = %ld", index);
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.dataArray.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.dataArray[section] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    THHomeTableViewCell *cell = (THHomeTableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"THHomeTableViewCell"];
    
    return cell;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    THInfoHeaderView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"THInfoHeaderView"];
    
    return headerView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
